import { Controller, Get, Post, Body } from '@nestjs/common';
import { PermissionService } from './permission.service';
import { CreatePermissionDto } from './dto/create-permission.dto';
import { ApiBearerAuth, ApiBody, ApiOperation } from '@nestjs/swagger';
import { Auth } from 'src/common/decorators/auth.decorator';

@Auth()
@ApiBearerAuth()
@Controller('permission')
export class PermissionController {
  constructor(private readonly permissionService: PermissionService) {}

  @Post('add')
  @ApiOperation({ summary: '创建权限', description: '创建一个或多个新的权限' })
  @ApiBody({
    type: [CreatePermissionDto],
    description: '权限创建数据传输对象数组',
  })
  create(@Body() createPermissionDto: CreatePermissionDto[]) {
    return this.permissionService.create(createPermissionDto);
  }

  @Get()
  findAll() {
    return this.permissionService.findAll();
  }
}
